<template>
  <div class="item-box">
    <block-header icon="/static/icon/sms.png" title="短信记录" :number="number"></block-header>
    <record-list :data="converseListTemp" v-if="converseListTemp.length > 0" :loadAll="loadAll"></record-list>
    <span v-else class="tip-null">暂无数据</span>
  </div>
</template>

<script>
  import BlockHeader from '../../components/block-header'
  import RecordList from '../../components/record-list'
  import request from '../../helper/request'

  export default {
    components: {
      BlockHeader,
      RecordList
    },
    props: {
      data: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    data() {
      return {
        converseList: [],
        converseListTemp: [],
        number: ''
      }
    },
    methods: {
      /**
       * 查看全部
       */
      loadAll() {
        this.$store.commit('updatePhone', this.data)
        this.$router.push('/sms-logs-file-all')
      },
      getQueryList(limit = 5) {
        let param = Object.assign({
          'sjh': '',
          'pageObj': {
            'currPage': 1,
            'pageSize': limit,
            'pagination': '1'
          }
        }, this.data)
        request('superRecord/mobile/txjl', 'SC042602', param).then(res => {
          this.number = res.pageResult.totalCount
          this.converseList = res.dxjl.map(resTH => {
            return {
              tableName: resTH.tableName,
              systemid: resTH.systemid,
              mobile: resTH.sjhm,
              name: resTH.xm,
              time: resTH.lastTime,
              count: resTH.num
            }
          })
          this.converseListTemp = this.converseList.slice(0, 5)
        }).catch(err => {
          this.$toast(err.msg)
        })
      }
    },
    created() {
      this.getQueryList()
    }
  }
</script>

<style lang="scss" scoped>

  ul {
    width: 100%;
    list-style: none;
    margin: 0;
    padding: 0;
    background-color: #fff;
    li {
      height: 85px;
      margin: 0 15px;
      display: flex;
      align-items: center;
      border-bottom: 1px solid #ddd;
      p {
        margin: 0;
        font-size: 18px;
      }
      .left {
        flex: 1;
        .mobile {
          color: #5078ac;
          margin-bottom: 5px;
        }
        .name {
          color: #000;
        }
      }
      .right {
        .time {
          text-align: right;
          margin-bottom: 5px;
        }
        .count {
          height: 22px;
          line-height: 22px;
          padding: 0 5px;
          color: #fff;
          background-color: #fe6601;
          text-align: center;
          border-radius: 3px;
          font-size: 15px;
          float: right;
        }
      }
    }
    .lookAll {
      height: 50px;
      line-height: 25px;
      text-align: center;
      font-size: 20px;
      border: 0;
      justify-content: center;
    }
  }
</style>
